

GitHub - janmaru/mahamudra-cryptography-notation: A simple package that implemen...
source link: https://github.com/janmaru/mahamudra-cryptography-notation
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

# Mahamudra.Cryptography.Notation
[Photo by Tezos on Unsplash]
EncodeBase58
What is Base58 encoding?
Base58 is a binary-to-text encoding created by Satoshi Nakamoto for Bitcoin addresses. The original Bitcoin client source code explains the reasoning behind base58 encoding:
base58.h:
Why base-58 instead of standard base-64 encoding?
- Don't want 0OIl characters that look the same in some fonts and could be used to create visually identical looking account numbers.
- A string with non-alphanumeric characters is not as easily accepted as an account number.
- E-mail usually won't line-break if there's no punctuation to break at.
- Doubleclicking selects the whole number as one word if it's all alphanumeric.
A simple package that implements the base-58 encoding.
Usage
member this.EncodePlainv2 (bdata:byte[]):string = let data = bdata |> Array.toList let rec toBigInt = function |[], acc -> acc |h::t, acc -> toBigInt(t, acc*256I + bigint(int h)) let rec base58encode = function | i,acc when i>0I -> let reminder = ref 0I let dividend = bigint.DivRem(i, 58I, reminder) let char = ArryDigits.[(int)reminder.contents] base58encode(dividend, char::acc) | _,acc -> acc let appendOnes = let rec insertOnes = function | h::t,acc when h=0uy -> insertOnes(t, '1'::acc) | _,acc -> acc insertOnes(data, []) let big = toBigInt(data, 0I) let encoded = appendOnes @ base58encode(big, []) |> List.toArray encoded |> System.String [<TestMethod>] member this.EncodePlain_ShouldGiveString1_True () = let value = [|0x00uy; 0x00uy; 0x00uy; 0x01uy |] let string1 = "1112"; let base58 = new Base58() let encoding = base58.EncodePlain(value); let encodingv2 = base58.EncodePlainv2(value); Assert.AreEqual(encoding, string1) Assert.AreEqual(encodingv2, string1)
Flaticon License
Free for personal and commercial purpose with attribution.
Recommend
-
172
maybe-baby 2.x will be maintained, however, if possible for your repository, you should opt to use TypeScript's optional...
-
110
math-as-code Chinese translation (中文版)
-
141
A simple and unified notation for both object data, like JSON, and markup data, like HTML and XML. (beta)
-
99
dlbook_notation - LaTeX files for the Deep Learning book notation
-
76
README.md Euler Euler uses custom operators in the "Math Symbols" character set to implement function...
-
7
A guide to implementing dark modes on websites Saturday, 28 September 2019 ∙ 6 minute read Previously I wrote about how to decide to ad...
-
9
pyca/cryptography cryptography is a package which provides cryptographic recipes and primitives to Python developers. Our goal is for it to be your "cryptographic standard library". It supports Python 3.6+ and PyPy3...
-
10
How soon is too soon to report progress from a C++/WinRT coroutine that implements a Windows Runtime asynchronous operation with progress?
-
6
BFFS - Backend for Frontend Shield BFFS is a simple project built with Laravel that implements the...
-
7
Download source code - 84.2 KB Introduction Decision trees are a popular machine learning algorithm used for both...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK