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
<?php | |
// Checks if the input text is Hebrew | |
function checkHebrew($str){ | |
preg_match('/[א-ת]/u', $str, $match); | |
return ( mb_detect_encoding($str, 'UTF-8', true) == 'UTF-8' && !empty($match[0]) ); | |
} | |
// Gets wrongly encoded text and outputs readable UTF-8 Hebrew | |
function ensureHebrew($str, $encodings = array('UTF16-LE', 'WINDOWS-1255')){ | |
if(!checkHebrew($str)){ |
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
function isracardCheck(num) { | |
if(num.length < 8 || num.length > 9) return false; | |
var diff = "987654321", | |
sum = 0, | |
a = 0, | |
b = 0, | |
c = 0; | |
if(num.length < 9) num = "0" + num; | |
for(var i=1;i<9;i++){ | |
sum += parseInt(diff.substr(i,1))*parseInt(num.substr(i,1)); |
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
<?php | |
function north_cast_api_data($content) { | |
if (is_numeric($content)) $content = intval($content); | |
else { | |
$unserialized_content = @unserialize($content); | |
// we got serialized content | |
if ($unserialized_content !== false) { | |
// make sure that integers are represented as such, instead of str | |
foreach ($unserialized_content as $fn => &$c) { |
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
std::vector<EncryptionStepDescriptor> loadKey(string path) { | |
int count = 0; | |
ifstream file; | |
// We're storing our loaded descriptors in a vector | |
std::vector<EncryptionStepDescriptor> descriptors; | |
file.open(path, ios::binary); | |
cout << "Reading Key..." << endl; | |
if (file.is_open()) { | |
while (file.good()) { | |
// This is our descriptor structure that is going to hold the data loaded directly from the binary |
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
std::vector<uint8_t> loadCipher(string path) { | |
int count = 0; | |
ifstream file; | |
std::vector<uint8_t> v; | |
file.open(path, ios::binary); | |
cout << "Reading Cipher..." << endl; | |
if (file.is_open()) { | |
while (file.good()) { | |
char c; | |
if (!file.read(&c, sizeof(c))) { |
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
uint8_t getDecryptedChar(uint8_t c, uint8_t operationCode, uint8_t operationParameter) { | |
switch (operationCode) { | |
case Xor: | |
return c ^ operationParameter; | |
break; | |
case Add: | |
return c + operationParameter; | |
break; | |
case Subtract: | |
return c - operationParameter; |
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
string getOperationName(uint8_t code) { | |
switch (code) { | |
case Xor: | |
return "Xor"; | |
break; | |
case Add: | |
return "Add"; | |
break; | |
case Subtract: | |
return "Subtract"; |
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
int main() | |
{ | |
// Load Key.bin into a vector of EncryptionStepDescriptor structures | |
std::vector<EncryptionStepDescriptor> descriptors = loadKey("C:\\Users\\Danny\\Documents\\Visual Studio 2015\\Projects\\LikeABoss\\Debug\\Key.bin"); | |
// Load the encrypted message | |
std::vector<uint8_t> v = loadCipher("C:\\Users\\Danny\\Documents\\Visual Studio 2015\\Projects\\LikeABoss\\Debug\\EncryptedMessage.bin"); | |
string str(v.begin(), v.end()); | |
// The cursor keeps track of our current position in the encrypted message |
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
// the "secret sauce" here is that everything has to happen at compile-time | |
// step 3) this gets called for every possible index at compile time | |
template <std::size_t index, class... Args> void visitor_impl(const std::variant<Args...>& variant) | |
{ | |
// this code path narrows us down to the type that's currently in the variant | |
if (variant.index() == index) | |
{ | |
// we now have the current value in a fully generic way | |
auto value = std::get<index>(variant); |