Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа №3 / DiffieHellmann / src / diffiehellmann / U
.java /*
* U.java
*
* Created on April 25, 2007, 11:28 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package diffiehellmann;
/**
*
* @author adm
*/
public class U {
/** Creates a new instance of U */
public U() {
}
/**
*
* return a ^ x mod n
*
*/
public static void log(String s) {
System.out.println(s);
}
public static long modexp( long a, long x, long n) {
long r;
r = 1;
while ( x > 0 )
{
if ( (x % 2) == 1 )
{
r = (r * a) % n ;
}
a = ( a * a ) % n ;
x /= 2;
}
return r ;
}
}
* U.java
*
* Created on April 25, 2007, 11:28 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package diffiehellmann;
/**
*
* @author adm
*/
public class U {
/** Creates a new instance of U */
public U() {
}
/**
*
* return a ^ x mod n
*
*/
public static void log(String s) {
System.out.println(s);
}
public static long modexp( long a, long x, long n) {
long r;
r = 1;
while ( x > 0 )
{
if ( (x % 2) == 1 )
{
r = (r * a) % n ;
}
a = ( a * a ) % n ;
x /= 2;
}
return r ;
}
}
Соседние файлы в папке diffiehellmann