-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
530 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[DecryptedText] | ||
Decrypted=https://github.com/n0connect/RSA | ||
|
||
[EncryptedHex] | ||
Hex=e2de3f24258d3014 136319082ad93d67 136319082ad93d67 ce71ab23ee1e20c1 156157712fdd12208 7886fee9c3926013 148aa195437fda068 148aa195437fda068 535b052d8c69c06a 145011dd9a08dedef 136319082ad93d67 e2de3f24258d3014 dc6023764f2723d8 dca6978160f38e2f 1441949ff8ab57fe3 3ac88876a3d123d4 f50d0aa4e135010a e5c54faf8a7aa2f 148aa195437fda068 11285e6c58e245cae c3126b6408b6e1ca 3ac88876a3d123d4 f50d0aa4e135010a 11285e6c58e245cae 11285e6c58e245cae 130472c43f3080a78 3ac88876a3d123d4 136319082ad93d67 148aa195437fda068 56bdd230068e47 750d912e20ba9a8a cf91c6937a326a7e | ||
|
||
[EncryptedText] | ||
Encrypted=16347573121882861588 1396987832284298599 1396987832284298599 14875859214988615873 24649739058933735944 8684909211392565267 23682769439988490344 23682769439988490344 6006400221216096362 23419032357842054639 1396987832284298599 16347573121882861588 15879731277149447128 15899562116411264559 23353778704599056355 4235785492677862356 17657781417258844426 1034795451278666287 23682769439988490344 19781470674462465198 14056415464363844042 4235785492677862356 17657781417258844426 19781470674462465198 19781470674462465198 21925541981228370552 4235785492677862356 1396987832284298599 23682769439988490344 24415558443634247 8434557304438430346 14956954174186744446 | ||
|
||
[Private] | ||
PrimeOne=5000999921 | ||
PrimeTwo=4999999937 | ||
|
||
[Public] | ||
Generator=65537 | ||
PublicKey=25004999289937004977 | ||
|
||
[SecretText] | ||
Seed=/RSA | ||
Text=https://github.com/n0connect | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#include <iostream> | ||
#include <gmpxx.h> | ||
#include <random> | ||
#include <chrono> | ||
#include <fstream> | ||
#include <string> | ||
#include <ownerr.h> | ||
|
||
// ** Istenilen bit uzunluğunda yüksek olasılıkla asal sayı üretir | ||
// ** Kullanılan algoritma "BPSW" (Bailey–Pomerance–Selfridge–Wagstaff) | ||
mpz_class GenerateRandomPrime(short int _bit_, short int _validator_) | ||
{ | ||
mpz_class prime; | ||
gmp_randstate_t state; | ||
|
||
gmp_randinit_default(state); | ||
gmp_randseed_ui(state, std::chrono::high_resolution_clock::now().time_since_epoch().count()); | ||
|
||
while (true) | ||
{ | ||
mpz_urandomb(prime.get_mpz_t(), state, _bit_); | ||
if (mpz_probab_prime_p(prime.get_mpz_t(), _validator_) != 0) | ||
break; | ||
} | ||
|
||
gmp_randclear(state); | ||
|
||
return prime; | ||
} | ||
|
||
// ** Hesaplanan Asalları kaydet | ||
void WritePrimesToFile(const std::string &fileName, const mpz_class &prime, short int _bit_, short int _validator_) | ||
{ | ||
std::ofstream outputFile(fileName, std::ios_base::app); // Dosyanın sonuna ekleme modunda aç | ||
if (!outputFile.is_open()) | ||
{ | ||
std::cerr << "Unable to open output file!" << std::endl; | ||
return; | ||
} | ||
|
||
outputFile << _bit_ << "BIT" | ||
<< " " << _validator_ << " " | ||
<< "Validator" | ||
<< " "; // Bit uzunluğu ve validator değerini dosyaya yaz | ||
outputFile << prime << std::endl; // Üretilen asal sayıyı dosyaya ekle | ||
outputFile.close(); | ||
} | ||
|
||
int main() | ||
{ | ||
short int _bit_ = 64; | ||
short int _validator_ = 2000; | ||
unsigned long long int primeCount{0}; | ||
|
||
try | ||
{ | ||
// ** Bilgilendirici mesajları ekrana yazdır | ||
std::cout << "Bit size determines the length of the prime number in bits." << std::endl; | ||
std::cout << "Validator size affects the certainty level of the primality test." << std::endl; | ||
std::cout << "A higher validator size results in a more rigorous primality check." << std::endl; | ||
|
||
// ** Kullanıcıdan bit ve validator boyutunu girmesini isteyen mesajları ekrana yazdır | ||
std::cout << "\nEnter the bit size (recommended: 256): "; | ||
std::cout << "\nEnter the validator size (recommended: 25): "; | ||
|
||
std::cout << "Enter the bit size: "; | ||
std::cin >> _bit_; | ||
|
||
std::cout << "Enter the validator size: "; | ||
std::cin >> _validator_; | ||
} | ||
catch (std::exception &ex) | ||
{ | ||
OwnErr(); | ||
} | ||
|
||
std::ofstream outputFile("probPrime.txt", std::ios_base::app); // Dosyanın sonuna ekleme modunda aç | ||
if (!outputFile.is_open()) | ||
{ | ||
std::cerr << "Unable to open output file!" << std::endl; | ||
return 1; | ||
} | ||
|
||
outputFile.close(); // Dosyayı kapat, yalnızca kontrol için açıldı | ||
|
||
mpz_class prime{}; | ||
|
||
while (primeCount < 10) | ||
{ | ||
prime = GenerateRandomPrime(_bit_, _validator_); | ||
WritePrimesToFile("probPrime.txt", prime, _bit_, _validator_); | ||
++primeCount; | ||
} | ||
|
||
// Üretilen asal sayıları ekrana yazdır | ||
std::ifstream inputFile("probPrime.txt"); | ||
if (inputFile.is_open()) | ||
{ | ||
std::string line; | ||
while (std::getline(inputFile, line)) | ||
{ | ||
std::cout << line << std::endl; | ||
} | ||
inputFile.close(); | ||
} | ||
else | ||
{ | ||
std::cerr << "Unable to open input file!" << std::endl; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
Binary file not shown.
Oops, something went wrong.