Skip to content

Instantly share code, notes, and snippets.

@ashfn
Created June 30, 2025 12:08
Show Gist options
  • Save ashfn/d58b57914e792453337ba1d2379c86a5 to your computer and use it in GitHub Desktop.
Save ashfn/d58b57914e792453337ba1d2379c86a5 to your computer and use it in GitHub Desktop.
Password Generator (DON'T USE IN PROD! :) )
#include <bits/stdc++.h>
using namespace std;
//
// *Pass@!#4
// google
uint64_t xorshift64(uint64_t state){
state ^= state << 13;
state ^= state >> 7;
state ^= state << 17;
return state;
}
uint64_t convert(string text){
uint64_t result = 0;
for(int i=0; i<9; i++){
if(i<text.length()){
result+=(int)text[i];
}
result = result<<7;
}
uint8_t runs = result>>56;
// cout << "runs:"<<(int)runs<<"\n";
for(int i=0; i<runs; i++){
result = xorshift64(result);
}
return result;
}
int main()
{
cout << "Enter root password: ";
string rootpass;
cin >> rootpass;
uint64_t rootpass_int = convert(rootpass);
cout << "\nEnter security key (number <100M): ";
int secKey;
cin >> secKey;w
cout << "\nEnter password name: ";
string passname;
cin >> passname;
uint64_t passname_int = convert(passname);
uint64_t password = (rootpass_int ^ passname_int);
for(int i=0; i<secKey; i++){
password = xorshift64(password);
}
cout << "Generated password: \n";
cout << hex << (password) << "\n";
return 0;
}
==========================================================================
Deterministic password generator
Uses XORSHIFT64 Pseudo Random Number generator
Probably not cryptographically secure but useful nonetheless
All you need to store all your passwords is a root password and a small security key
You remember those two and the name of the password and you will always be able to get the same
password by running the program
==========================================================================Try
Root password = Ash921!
Security key = 827123
Password for google
Do you get 4f0c49edef1d04a7?
==========================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment