コード例 #1
0
        public void Base62Test()
        {
            // string test
            var converter  = new Base62Converter();
            var testString = "Lorem ipsum dolor sit amet.";

            byte[] testStringBytes  = Encoding.ASCII.GetBytes(testString);
            string testStringBase62 = converter.ToBase62String(testStringBytes);

            byte[] finalBytes  = converter.FromBase62String(testStringBase62);
            string finalString = Encoding.ASCII.GetString(finalBytes);

            Assert.AreEqual(testString, finalString);

            // byte test
            var data = new byte[] {
                0, 0, 0, 1, 2, 3, 255, 128, 0, 4, 0
            };
            string dataBase62String = converter.ToBase62String(data);

            byte[] finalData = converter.FromBase62String(dataBase62String);
            CollectionAssert.AreEqual(data, finalData);
        }
コード例 #2
0
 public static string ToBase62(byte[] bytes)
 {
     return(Base62Converter.ToBase62String(bytes));
 }