示例#1
0
    public static long Decrypt(long value, long key)
    {
        if (key == 0)
        {
            key = cryptoKey;
        }

        var u = new LongLongBytesUnion();

        u.l = value ^ key;
        return(u.d);
    }
示例#2
0
    public void SetEncrypted(long encrypted)
    {
        var union = new LongLongBytesUnion();

        union.l = encrypted;

        hiddenValue[0] = union.b1;
        hiddenValue[1] = union.b2;
        hiddenValue[2] = union.b3;
        hiddenValue[3] = union.b4;
        hiddenValue[4] = union.b5;
        hiddenValue[5] = union.b6;
        hiddenValue[6] = union.b7;
        hiddenValue[7] = union.b8;
    }
示例#3
0
    private static void InternalEncrypt(byte[] bytes, long value, long key = 0)
    {
        if (key == 0)
        {
            key = cryptoKey;
        }

        var u = new LongLongBytesUnion();

        u.d = value;
        u.l = u.l ^ key;

        bytes[0] = u.b1;
        bytes[1] = u.b2;
        bytes[2] = u.b3;
        bytes[3] = u.b4;
        bytes[4] = u.b5;
        bytes[5] = u.b6;
        bytes[6] = u.b7;
        bytes[7] = u.b8;
    }
示例#4
0
    public long GetEncrypted()
    {
        if (currentCryptoKey != cryptoKey)
        {
            long temp = InternalDecrypt();
            InternalEncrypt(hiddenValue, temp, cryptoKey);
            currentCryptoKey = cryptoKey;
        }

        var union = new LongLongBytesUnion();

        union.b1 = hiddenValue[0];
        union.b2 = hiddenValue[1];
        union.b3 = hiddenValue[2];
        union.b4 = hiddenValue[3];
        union.b5 = hiddenValue[4];
        union.b6 = hiddenValue[5];
        union.b7 = hiddenValue[6];
        union.b8 = hiddenValue[7];

        return(union.l);
    }
示例#5
0
    private long InternalDecrypt()
    {
        long key = cryptoKey;

        if (currentCryptoKey != cryptoKey)
        {
            key = currentCryptoKey;
        }

        var union = new LongLongBytesUnion();

        union.b1 = hiddenValue[0];
        union.b2 = hiddenValue[1];
        union.b3 = hiddenValue[2];
        union.b4 = hiddenValue[3];
        union.b5 = hiddenValue[4];
        union.b6 = hiddenValue[5];
        union.b7 = hiddenValue[6];
        union.b8 = hiddenValue[7];

        union.l = union.l ^ key;

        return(union.d);
    }