Browse Source

clean code

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/65/head
R4SAS 4 years ago
parent
commit
5f45990dff
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 2
      b33address.cpp
  2. 6
      famtool.cpp
  3. 3
      i2pbase64.cpp
  4. 18
      keyinfo.cpp
  5. 4
      regaddralias.cpp
  6. 38
      vanitygen.cpp

2
b33address.cpp

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
int main(int argc, char * argv[])
{
// base64 input, b33 and store key output, 11->11 only
std::cout << "Waiting for base64 from stdin..." << std::endl;
std::string base64;
std::getline (std::cin, base64);
auto ident = std::make_shared<i2p::data::IdentityEx>();
@ -27,4 +28,3 @@ int main(int argc, char * argv[]) @@ -27,4 +28,3 @@ int main(int argc, char * argv[])
return 0;
}

6
famtool.cpp

@ -277,13 +277,13 @@ int main(int argc, char * argv[]) @@ -277,13 +277,13 @@ int main(int argc, char * argv[])
if (sign) {
// sign
if (!infile.size()) {
// no router info specififed
// no router info specified
std::cerr << "no router keys file specified" << std::endl;
return 1;
}
if (!privkey.size()) {
// no private key specified
std::cerr << "no private key specififed" << std::endl;
std::cerr << "no private key specified" << std::endl;
return 1;
}
@ -345,7 +345,7 @@ int main(int argc, char * argv[]) @@ -345,7 +345,7 @@ int main(int argc, char * argv[])
return 1;
}
if(!certfile.size()) {
std::cout << "no family cerifiticate specified" << std::endl;
std::cout << "no family certificate specified" << std::endl;
return 1;
}
auto v = LoadCertificate(certfile);

3
i2pbase64.cpp

@ -36,9 +36,6 @@ static int operate(std::function<std::size_t(const InCh *, size_t, OutCh *, size @@ -36,9 +36,6 @@ static int operate(std::function<std::size_t(const InCh *, size_t, OutCh *, size
return errno;
}
int main(int argc, char * argv[])
{
int opt;

18
keyinfo.cpp

@ -9,6 +9,11 @@ @@ -9,6 +9,11 @@
#include <time.h>
#include "common/key.hpp"
static int printHelp(const char * exe, int exitcode)
{
std::cout << "usage: " << exe << " [-v] [-d] privatekey.dat" << std::endl;
return exitcode;
}
std::string ConvertTime (time_t t)
{
@ -21,14 +26,16 @@ std::string ConvertTime (time_t t) @@ -21,14 +26,16 @@ std::string ConvertTime (time_t t)
int main(int argc, char * argv[])
{
if(argc == 1) {
std::cout << "usage: " << argv[0] << " [-v] [-d] privatekey.dat" << std::endl;
return -1;
return printHelp(argv[0], -1);
}
int opt;
bool print_full = false;
bool verbose = false;
while((opt = getopt(argc, argv, "vd"))!=-1) {
while((opt = getopt(argc, argv, "hvd")) != -1) {
switch(opt){
case 'h':
return printHelp(argv[0], 0);
case 'v':
verbose = true;
break;
@ -36,10 +43,10 @@ int main(int argc, char * argv[]) @@ -36,10 +43,10 @@ int main(int argc, char * argv[])
print_full = true;
break;
default:
std::cout << "usage: " << argv[0] << " [-v] [-d] privatekey.dat" << std::endl;
return -1;
return printHelp(argv[0], -1);
}
}
std::string fname(argv[optind]);
i2p::data::PrivateKeys keys;
{
@ -60,6 +67,7 @@ int main(int argc, char * argv[]) @@ -60,6 +67,7 @@ int main(int argc, char * argv[])
return 3;
}
}
auto dest = keys.GetPublic();
if(!dest) {
std::cout << "failed to extract public key" << std::endl;

4
regaddralias.cpp

@ -33,7 +33,7 @@ int main (int argc, char * argv[]) @@ -33,7 +33,7 @@ int main (int argc, char * argv[])
}
else
{
std::cout << "Cab't open keyfile " << argv[1] << std::endl;
std::cout << "Can't open keyfile " << argv[1] << std::endl;
return -1;
}
}
@ -56,7 +56,7 @@ int main (int argc, char * argv[]) @@ -56,7 +56,7 @@ int main (int argc, char * argv[])
}
else
{
std::cout << "Cab't open keyfile " << argv[2] << std::endl;
std::cout << "Can't open keyfile " << argv[2] << std::endl;
return -1;
}
}

38
vanitygen.cpp

@ -3,20 +3,20 @@ @@ -3,20 +3,20 @@
#include<getopt.h>
static struct{
static struct
{
bool reg=false;
int threads=-1;
i2p::data::SigningKeyType signature;
std::string outputpath="";
std::regex regex;
} options;
static void inline CalculateW (const uint8_t block[64], uint32_t W[64])
{
/*
implementation of orignal
/**
* implementation of orignal
*/
for (int i = 0; i < 16; i++)
#ifdef _WIN32
@ -31,8 +31,8 @@ implementation of orignal @@ -31,8 +31,8 @@ implementation of orignal
static void inline TransformBlock (uint32_t state[8], const uint32_t W[64])
{
/*
implementation of orignal
/**
* implementation of orignal
*/
uint32_t S[8];
memcpy(S, state, 32);
@ -60,8 +60,8 @@ implementation of orignal @@ -60,8 +60,8 @@ implementation of orignal
void inline HashNextBlock (uint32_t state[8], const uint8_t * block)
{
/*
implementation of orignal
/**
* implementation of orignal
*/
uint32_t W[64];
CalculateW (block, W);
@ -126,10 +126,10 @@ static inline bool NotThat(const char * a, const char *b) @@ -126,10 +126,10 @@ static inline bool NotThat(const char * a, const char *b)
static inline bool thread_find(uint8_t * buf, const char * prefix, int id_thread, unsigned long long throughput)
{
/*
Thanks to orignal ^-^
For idea and example ^-^
Orignal is sensei of crypto ;)
/**
* Thanks to orignal ^-^
* For idea and example ^-^
* Orignal is sensei of crypto ;)
*/
std::cout << "Thread " << id_thread << " binded" << std::endl;
/*
@ -208,10 +208,6 @@ Orignal is sensei of crypto ;) @@ -208,10 +208,6 @@ Orignal is sensei of crypto ;)
return true;
}
void usage(void){
const constexpr char * help="vain [text-pattern|regex-pattern] [options]\n"
"-h --help, help menu\n"
@ -225,7 +221,6 @@ void usage(void){ @@ -225,7 +221,6 @@ void usage(void){
puts(help);
}
void parsing(int argc, char ** args){
int option_index;
static struct option long_options[]={
@ -274,10 +269,6 @@ void parsing(int argc, char ** args){ @@ -274,10 +269,6 @@ void parsing(int argc, char ** args){
int main (int argc, char * argv[])
{
if ( argc < 2 )
{
usage();
@ -320,7 +311,7 @@ int main (int argc, char * argv[]) @@ -320,7 +311,7 @@ int main (int argc, char * argv[])
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA384_3072:
case i2p::data::SIGNING_KEY_TYPE_RSA_SHA512_4096:
case i2p::data::SIGNING_KEY_TYPE_GOSTR3410_TC26_A_512_GOSTR3411_512:
std::cout << "Sorry, i don't can generate adress for this signature type" << std::endl;
std::cout << "Sorry, i don't can generate address for this signature type" << std::endl;
return 0;
break;
}
@ -413,6 +404,3 @@ int main (int argc, char * argv[]) @@ -413,6 +404,3 @@ int main (int argc, char * argv[])
return 0;
}
//

Loading…
Cancel
Save