示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            hasher h      = new hasher();
            string output = h.base64_encode(textBox1.Text);

            //base64 bs = new base64();
            //string output = bs.encode(textBox1.Text);

            textBox2.Text = output;
        }
示例#2
0
        public void Base64EncodeTest()
        {
            /**
             * SQL: SELECT TO_BASE64("A quick brown fox jumps over the lazy dog.");
             * PHP: php -r "echo base64_encode('A quick brown fox jumps over the lazy dog.');"
             *
             * QSBxdWljayBicm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cu
             */
            hasher h      = new hasher();
            string hash   = h.base64_encode("A quick brown fox jumps over the lazy dog.");
            string expect = "QSBxdWljayBicm93biBmb3gganVtcHMgb3ZlciB0aGUgbGF6eSBkb2cu";

            Assert.AreEqual(expect, hash);
        }
示例#3
0
        public void Base64UnicodeTest()
        {
            /**
             * SQL: SELECT TO_BASE64('क का कि की कु कू के कै को कौ');
             * PHP: php -r "echo base64_decode('क का कि की कु कू के कै को कौ');" -- failing
             *
             * SQL: SELECT TO_BASE64('क का कि की कु कू के कै को कौ');
             * 4KSVIOCkleCkviDgpJXgpL8g4KSV4KWAIOCkleClgSDgpJXgpYIg4KSV4KWHIOCkleCliCDgpJXgpYsg4KSV4KWM
             */
            string original       = "क का कि की कु कू के कै को कौ";
            string expect_encoded = "4KSVIOCkleCkviDgpJXgpL8g4KSV4KWAIOCkleClgSDgpJXgpYIg4KSV4KWHIOCkleCliCDgpJXgpYsg4KSV4KWM";

            hasher h       = new hasher();
            string encoded = h.base64_encode(original);
            string decoded = h.base64_decode(encoded);

            Assert.AreEqual(expect_encoded, encoded);
            Assert.AreEqual(original, decoded);
        }