Uncategorised
- Details
- Written by Pham Ngoc Hai
I was trying to upgrade my Filezilla from 3.0.3 to 3.0.4 today and getting this error:
[code]checking for wxWidgets version >= 2.8.6... no (version 2.6.4 is not new enough)
configure: error:
wxWidgets must be installed on your system
but wx-config script couldn't be found.
Please check that wx-config is in path, the directory
where wxWidgets libraries are installed (returned by
'wx-config --libs' command) is in LD_LIBRARY_PATH or
equivalent variable and wxWidgets version is 2.8.6 or above.
!!! Please attach the following file when filing a report to bugs.gentoo.org:
!!! /var/tmp/portage/portage/net-ftp/filezilla-3.0.4/work/filezilla-3.0.4/config.log[/code]
After a few minutes of googling without any possitve result, I found out that I need to set eselect wxwidgets to 2.8.6
so:
[code]eselect wxwidgets list
Available wxWidgets profiles:
[1] gtk2-ansi-release-2.6 *
[2] gtk2-unicode-release-2.6
[3] gtk2-unicode-release-2.8[/code]
then:
[code]eselect wxwidgets set 3
Setting wxWidgets profile to gtk2-unicode-release-2.8
eselect wxwidgets list
Available wxWidgets profiles:
[1] gtk2-ansi-release-2.6
[2] gtk2-unicode-release-2.6
[3] gtk2-unicode-release-2.8 *[/code]
Then FileZilla was happily compiled.
- Details
- Written by Pham Ngoc Hai
It's here: http://svn2.assembla.com/svn/pnh/
That's my personal gentoo overlay in which you'll find ebuilds that I created myself (you can find them on this site) as well as ebuilds that I copied from others.
Use it at your own risk.
For those who has not got layman, you need to emerge layman first:
[code]emerge -av layman[/code]
Now you're ready to add my overlay:
[code]layman -o http://phamngochai.net/myfiles/overlay/pnh.xml -a pnh[/code]
And that's it.
If you get an error, then this may work:
[code]layman -o http://phamngochai.net/myfiles/overlay/pnh.xml -L
layman -a pnh[/code]
Remember to run
[code]layman --sync ALL[/code]
to get the lastest ebuilds from overlays.
=====================
Updated 16th Aug 2009
In case all those commands above dont work for you, you may want to try:
[code]layman -o http://phamngochai.net/myfiles/overlay/pnh.xml -s -a pnh[/code]
- Details
- Written by Pham Ngoc Hai
This is one of my class assignment in Security, please take a look at my Miller-Rabin prime number test for more information.
Enjoy.
[code]import java.math.*;
import java.util.*;
public class MyRSA {
private static Random aRand;
private static BigInteger n;
private static BigInteger pn;
private static BigInteger e;
private static BigInteger d;
private static BigInteger IV;
private static BigInteger p, q;
private static final int MAX_BIT = 1024;
private static final int MAX_TRY = 5;
private static final int CHR_SIZE = 8;
private static final BigInteger ONE = BigInteger.valueOf(1);
private static int blocLength;
private static int ZN = 256;
private static String myPadding = "The wolrd wonders";
public MyRSA(Random aRandom) {
aRand = aRandom;
generatePQ(aRand);
findED();
}
public BigInteger getN() {
return n;
}
public BigInteger getE() {
return e;
}
public BigInteger getD() {
return d;
}
public static BigInteger RSAEncrypt(BigInteger m) {
return m.modPow(e, n);
}
public static BigInteger RSADecrypt(BigInteger c) {
return c.modPow(d, n);
}
public static BigInteger RSAEncrypt(BigInteger am, BigInteger an, BigInteger ae) {
return am.modPow(ae, an);
}
public static BigInteger RSADecrypt(BigInteger ac, BigInteger an, BigInteger ad) {
return ac.modPow(ad, an);
}
public String RSAEncryptBloc(String aString) {
String result = "";
Vector<String> aVectorMStr = new Vector<String>();
Vector<String> aVectorCStr = new Vector<String>();
Vector<BigInteger> aVectorMInt = new Vector<BigInteger>();
Vector<BigInteger> aVectorCInt = new Vector<BigInteger>();
blocLength = findBlocLength();
genIV(blocLength);
aVectorMStr = chopStringToAsciiBlocs(aString, blocLength, true);
aVectorMInt = getBigIntVector(aVectorMStr);
for (int i = 0; i < aVectorMInt.size(); i++) {
if (i == 0) {
aVectorCInt.add(RSAEncrypt(aVectorMInt.elementAt(0).xor(IV)));
} else {
aVectorCInt.add(RSAEncrypt(aVectorMInt.elementAt(i).xor(aVectorCInt.elementAt(i - 1))));
}
}
aVectorCStr = getAsciiVector(aVectorCInt);
for(int i = 0; i < aVectorCStr.size(); i++) {
result += aVectorCStr.elementAt(i);
}
return result;
}
public String RSADecryptBloc(String aString) {
String result = "";
Vector<String> aVectorCStr = new Vector<String>();
Vector<String> aVectorMStr = new Vector<String>();
Vector<BigInteger> aVectorCInt = new Vector<BigInteger>();
Vector<BigInteger> aVectorMInt = new Vector<BigInteger>();
aVectorCStr = chopStringToAsciiBlocs(aString, blocLength + 1, false);
aVectorCInt = getBigIntVector(aVectorCStr);
for (int i = 0; i < aVectorCInt.size(); i++) {
if (i == 0) {
aVectorMInt.add(RSADecrypt(aVectorCInt.elementAt(0)).xor(IV));
} else {
aVectorMInt.add(RSADecrypt(aVectorCInt.elementAt(i)).xor(aVectorCInt.elementAt(i - 1)) );
}
}
aVectorMStr = getAsciiVector(aVectorMInt);
for (int i = 0; i < aVectorMStr.size(); i++) {
result += aVectorMStr.elementAt(i);
}
result = removePadding(result);
return result;
}
public static Vector<String> getAsciiVector(Vector<BigInteger> aVectorInt) {
Vector<String> aVectorStr = new Vector<String>();
for (int i = 0; i < aVectorInt.size(); i++) {
aVectorStr.add(convertBigIntegerToAsciiBlocBaseN(aVectorInt.elementAt(i)));
}
return aVectorStr;
}
public static String convertBigIntegerToAsciiBlocBaseN(BigInteger aBigInt) {
String result = "";
int t;
Vector<Character> aCharVector = new Vector<Character>();
BigInteger m = aBigInt;
do {
t = m.mod(BigInteger.valueOf(ZN)).intValue();
m = m.divide(BigInteger.valueOf(ZN));
char c = (char)t;
aCharVector.add(new Character(c));
}while (m.compareTo(BigInteger.ZERO) > 0);
for (int i = 0; i < aCharVector.size(); i++ ) {
result += aCharVector.elementAt(i);
}
return result;
}
public static Vector<BigInteger> getBigIntVector(Vector<String> aVectorStr) {
Vector<BigInteger> aVectorBigInt = new Vector<BigInteger>();
for (int i = 0; i < aVectorStr.size(); i++) {
aVectorBigInt.add(convertAsciiBloctToBigIntegerBaseN(aVectorStr.elementAt(i)));
}
return aVectorBigInt;
}
public static BigInteger convertAsciiBloctToBigIntegerBaseN(String aString) {
BigInteger result = BigInteger.ZERO;
for (int i = 0; i < aString.length(); i++) {
int n = (char)aString.charAt(i);
result = result.add(BigInteger.valueOf(ZN).pow(i).multiply(BigInteger.valueOf(n)));
}
return result;
}
public static int findBlocLength() {
int l = 0;
BigInteger t = n;
while(t.compareTo(BigInteger.valueOf(ZN)) > 0) {
t = t.subtract(t.remainder(BigInteger.valueOf(ZN)));
t = t.divide(BigInteger.valueOf(ZN));
l++;
}
return l;
}
private static void generatePQ(Random aRand) {
p = new BigInteger(MAX_BIT, MAX_TRY, aRand);
do {
q = new BigInteger(MAX_BIT, MAX_TRY, aRand);
} while (q.compareTo(p) == 0);
n = p.multiply(q);
pn = (p.subtract(ONE)).multiply(q.subtract(ONE));
//System.out.println("p: " + p.toString());
//System.out.println("q: " + q.toString());
//System.out.println("n: " + n.toString());
//System.out.println("pn: " + pn.toString());
}
private static void findED() {
BigInteger aGCD;
do {
e = myBigRanNum(MAX_BIT);
if (e.compareTo(pn) >= 0) e = e.mod(pn);
aGCD = gcd(e, pn);
//System.out.println("e: " + e.toString());
} while (e.compareTo(BigInteger.ZERO) == 0 || e.compareTo(BigInteger.ONE) == 0 || aGCD.compareTo(BigInteger.ONE) != 0);
//System.out.println("e: " + e.toString());
d = ModInverse(e, pn);
//d = e.modInverse(pn);
//System.out.println("d: " + d.toString());
}
public static void genIV(int blocLength) {
IV = new BigInteger(blocLength * CHR_SIZE, aRand);
}
public static Vector<String> chopStringToAsciiBlocs(String aString, int blocLength, boolean padding) {
Vector<String> aVectorStr = new Vector<String>();
String tmp = aString;
do {
if (tmp.length() > blocLength) {
String m = tmp.substring(0, blocLength);
tmp = tmp.substring(blocLength);
aVectorStr.add(m);
//System.out.println("chop > : " + m);
} else if (tmp.length() == blocLength) {
aVectorStr.add(tmp);
//System.out.println("chop = : " + tmp);
if (padding) aVectorStr.add(addPadding("", blocLength));
break;
} else {
//System.out.println("chop < : " + tmp);
if (padding) aVectorStr.add(addPadding(tmp, blocLength));
break;
}
} while (true);
return aVectorStr;
}
public static String addPadding(String m, int l) {
String result = m;
int i = 0;
do {
result = result + myPadding.charAt(i);
i++;
if (i >= myPadding.length()) {
i = 0;
}
} while (result.length() < l);
return result;
}
public static String removePadding(String aString) {
String result = aString;
String tmp = "";
for (int i = 0; i < myPadding.length(); i++) {
tmp = myPadding.substring(0, myPadding.length() - 1 -i );
if (result.endsWith(tmp)) {
result = result.substring(0, result.indexOf(tmp));
break;
}
}
return result;
}
public static BigInteger gcd(BigInteger x, BigInteger y) {
BigInteger a = x;
BigInteger b = y;
while (b.compareTo(BigInteger.ZERO) != 0) {
BigInteger t = b;
b = a.mod(b);
a = t;
}
return a;
}
public static BigInteger ModInverse(BigInteger mx, BigInteger my) {
BigInteger a = mx;
BigInteger b = my;
BigInteger x = BigInteger.ZERO;
BigInteger y = BigInteger.ONE;
BigInteger lx = BigInteger.ONE;
BigInteger ly = BigInteger.ZERO;
while (b.compareTo(BigInteger.ZERO) != 0) {
//System.out.print(a.toString() + " " + b.toString() + " ");
BigInteger t = b;
b = a.mod(b);
BigInteger q = (a.subtract(b)).divide(t);
//System.out.println(q.toString());
a = t;
t = x;
x = lx.subtract(q.multiply(x));
lx = t;
t = y;
y = ly.subtract(q.multiply(y));
ly = t;
}
if (lx.compareTo(BigInteger.ZERO) < 0) lx = lx.add(my);
return lx;
}
public static BigInteger myBigRanNum(int numBits) {
//We only deal with positive number
BigInteger aBigInterger = new BigInteger(numBits, aRand);
aBigInterger = aBigInterger.abs();
return aBigInterger;
}
}[/code]
- Details
- Written by Pham Ngoc Hai
net-p2p/amule/amule-2.2.0_pre20071203.ebuild
Here's the ebuild for aMule cvs - the daily preview (current is 20071203).
The ebuild file name is amule-2.2.0_pre20071203.ebuild
[code]# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-p2p/amule/amule-2.2.0_pre20071203.ebuild,v 1.1 2007/12/03 11:48:32 armin76 Exp $
inherit eutils flag-o-matic wxwidgets
MY_P=${PN/m/M}-CVS-${PV/2.2.0_pre/}
S="${WORKDIR}/${PN}-cvs"
DESCRIPTION="aMule, the all-platform eMule p2p client"
HOMEPAGE="http://www.amule.org/"
SRC_URI="http://www.hirnriss.net/files/cvs/${MY_P}.tar.bz2"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~sparc ~x86"
IUSE="amuled debug gtk nls remote stats unicode"
DEPEND=">=x11-libs/wxGTK-2.8.0
>=sys-libs/zlib-1.2.1
stats? ( >=media-libs/gd-2.0.26 )
remote? ( >=media-libs/libpng-1.2.0
unicode? ( >=media-libs/gd-2.0.26 ) )"
pkg_setup() {
export WX_GTK_VER="2.8"
if ! use gtk && ! use remote && ! use amuled; then
eerror ""
eerror "You have to specify at least one of gtk, remote or amuled"
eerror "USE flag to build amule."
eerror ""
die "Invalid USE flag set"
fi
if use gtk; then
einfo "wxGTK with gtk2 and unicode support will be used"
need-wxwidgets unicode
elif use unicode; then
einfo "wxGTK with unicode and without X support will be used"
need-wxwidgets base-unicode
else
einfo "wxGTK without X support will be used"
need-wxwidgets base
fi
if use stats && ! use gtk; then
einfo "Note: You would need both the gtk and stats USE flags"
einfo "to compile aMule Statistics GUI."
einfo "I will now compile console versions only."
fi
if use stats && ! built_with_use media-libs/gd jpeg; then
die "media-libs/gd should be compiled with the jpeg use flag when you have the stats use flag set"
fi
}
pkg_preinst() {
if use amuled || use remote; then
enewgroup p2p
enewuser p2p -1 -1 /home/p2p p2p
fi
}
src_compile() {
local myconf=""
if use gtk ; then
use stats && myconf="${myconf}
--enable-wxcas
--enable-alc"
use remote && myconf="${myconf}
--enable-amule-gui"
else
myconf="
--disable-monolithic
--disable-amule-gui
--disable-wxcas
--disable-alc"
fi
econf \
--with-wx-config=${WX_CONFIG} \
--with-wxbase-config=${WX_CONFIG} \
--enable-amulecmd \
`use_enable debug` \
`use_enable !debug optimize` \
`use_enable amuled amule-daemon` \
`use_enable nls` \
`use_enable remote webserver` \
`use_enable stats cas` \
`use_enable stats alcc` \
${myconf} || die
# we filter ssp until bug #74457 is closed to build on hardened
filter-flags -fstack-protector -fstack-protector-all
emake -j1 || die
}
src_install() {
make DESTDIR=${D} install || die
if use amuled; then
newconfd ${FILESDIR}/amuled.confd amuled
newinitd ${FILESDIR}/amuled.initd amuled
fi
if use remote; then
newconfd ${FILESDIR}/amuleweb.confd amuleweb
newinitd ${FILESDIR}/amuleweb.initd amuleweb
fi
}[/code]
- Details
- Written by Pham Ngoc Hai
I found a bug in blogSidebar 2.4 component.
When the admin changes the values in the component setting,
those settings are not saved.
Empty values go in to the config file, this makes the side
bar module not find the correct setting so it displays
nothing when users click on the date in the calendar.
A simple fix is to put those lines:
[code]$columns = mosGetParam($_REQUEST, 'columns');
$intro = mosGetParam($_REQUEST, 'intro');
$leading = mosGetParam($_REQUEST, 'leading');
$links = mosGetParam($_REQUEST, 'links');[/code]
above the line:
[code]saveConfig ($option, $columns, $intro, $leading, $links);[/code]
in /administrator/components/com_blogsidebar/admin.blogsidebar.php
Page 9 of 11