diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..eb6fe11 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + mariadb + true + org.mariadb.jdbc.Driver + jdbc:mariadb://127.0.0.1:3306/socialbox + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8eb3216 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/.idea/php-test-framework.xml b/.idea/php-test-framework.xml new file mode 100644 index 0000000..2164112 --- /dev/null +++ b/.idea/php-test-framework.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml new file mode 100644 index 0000000..3b3a3cb --- /dev/null +++ b/.idea/sqldialects.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/webResources.xml b/.idea/webResources.xml new file mode 100644 index 0000000..77233d9 --- /dev/null +++ b/.idea/webResources.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..7275585 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +{"version":1,"defects":{"SocialBox\\Objects\\RpcRequestTest::testConstructorWithIdAndParametersMissing":4,"SocialBox\\Objects\\RpcRequestTest::testConstructorWithAllParametersPresent":4,"Error":4,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPairThrowsExceptionOnFailure with data set #0":5,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPair":8,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPairException":7,"Socialbox\\Classes\\CryptographyTest::testTemporarySignature":8,"Socialbox\\Classes\\CryptographyTest::testVerifyTemporarySignature":8,"Socialbox\\Classes\\CryptographyTest::testEncrypt":8,"Socialbox\\Classes\\CryptographyTest::testDecrypt":8,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithValidPublicKey":8,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithEmptyPublicKey":7,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithDbException":7,"Socialbox\\Managers\\SessionManagerTest::testCreateSession":8,"Socialbox\\Classes\\CryptographyTest::testSignContent":8,"Socialbox\\Classes\\CryptographyTest::testVerifyContent":8,"Socialbox\\Classes\\CryptographyTest::testDecryptFromFile":7,"Socialbox\\Managers\\SessionManagerTest::testGetSessionWithInvalidUuid":8,"Socialbox\\Managers\\SessionManagerTest::testGetSessionWithValidUuid":8,"Socialbox\\Managers\\SessionManagerTest::testUpdateSessionWithValidSessionRecord":8,"Socialbox\\Managers\\SessionManagerTest::testUpdateSessionWithInvalidUuid":7,"Socialbox\\Managers\\SessionManagerTest::testUpdateAuthenticatedPeerWithInvalidUuid":7,"Socialbox\\Managers\\SessionManagerTest::testUpdateAuthenticatedPeerWithValidUuid":8,"Socialbox\\Managers\\SessionManagerTest::testUpdateLastRequestWithInvalidUuid":7,"Socialbox\\Managers\\SessionManagerTest::testUpdateLastRequest":8,"Socialbox\\Classes\\CryptographyTest::testValidatePublicKey":7},"times":{"SocialBox\\Objects\\RpcRequestTest::testConstructorWithIdAndParametersMissing":0.001,"SocialBox\\Objects\\RpcRequestTest::testConstructorWithAllParametersPresent":0,"Error":0,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPair with data set #0":0.007,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPairThrowsExceptionOnFailure with data set #0":0.224,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPair":0.142,"Socialbox\\Classes\\CryptographyTest::testGenerateKeyPairException":0.114,"Socialbox\\Classes\\CryptographyTest::testSignContent":0.382,"Socialbox\\Classes\\CryptographyTest::testVerifyContent":0.5,"Socialbox\\Classes\\CryptographyTest::testTemporarySignature":0.198,"Socialbox\\Classes\\CryptographyTest::testVerifyTemporarySignature":0.253,"Socialbox\\Classes\\CryptographyTest::testEncrypt":0.117,"Socialbox\\Classes\\CryptographyTest::testDecrypt":0.506,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithValidPublicKey":0.004,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithEmptyPublicKey":0.002,"Socialbox\\Managers\\SessionManagerTest::testCreateSessionWithDbException":0.053,"Socialbox\\Managers\\SessionManagerTest::testCreateSession":0.339,"Socialbox\\Classes\\CryptographyTest::testEncryptFromFile":0.002,"Socialbox\\Classes\\CryptographyTest::testDecryptFromFile":0.004,"Socialbox\\Managers\\SessionManagerTest::testGetSessionWithInvalidUuid":0.002,"Socialbox\\Managers\\SessionManagerTest::testGetSessionWithValidUuid":0.297,"Socialbox\\Managers\\SessionManagerTest::testUpdateSessionWithValidSessionRecord":0.249,"Socialbox\\Managers\\SessionManagerTest::testUpdateSessionWithInvalidUuid":0.183,"Socialbox\\Managers\\SessionManagerTest::testUpdateAuthenticatedPeerWithInvalidUuid":0.002,"Socialbox\\Managers\\SessionManagerTest::testUpdateAuthenticatedPeerWithValidUuid":0.32,"Socialbox\\Managers\\SessionManagerTest::testUpdateLastRequestWithInvalidUuid":0.001,"Socialbox\\Managers\\SessionManagerTest::testUpdateLastRequest":0.441,"Socialbox\\Classes\\CryptographyTest::testValidatePublicKey":0.362,"Socialbox\\Classes\\CryptographyTest::testValidateInvalidPublicKey":0.003,"Socialbox\\Classes\\CryptographyTest::testValidatePrivateKey":0.184,"Socialbox\\Classes\\CryptographyTest::testValidateInvalidPrivateKey":0.004}} \ No newline at end of file diff --git a/examples/index.php b/examples/index.php new file mode 100644 index 0000000..52926d0 --- /dev/null +++ b/examples/index.php @@ -0,0 +1,6 @@ + 0; j--) { + if (crc & 1) { + crc = (crc >>> 1) ^ 0xEDB88320; + } else { + crc = crc >>> 1; + } + } + crcTable[i] = crc; + } + + var crc32val = 0xFFFFFFFF; + for (var i = 0; i < str.length; i++) { + var charCode = str.charCodeAt(i); + crc32val = (crc32val >>> 8) ^ crcTable[(crc32val ^ charCode) & 0xFF]; + } + + return (crc32val ^ 0xFFFFFFFF) >>> 0; +} + +export function randomCrc32String(length = 8) { + var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + var randomStr = ''; + for (var i = 0; i < length; i++) { + randomStr += characters.charAt(Math.floor(Math.random() * characters.length)); + } + return crc32(randomStr).toString(16); // Convert to hexadecimal string +} + +console.log(randomCrc32String()); // Example usage