Golang encoding/ascii85.Decode function example
package encoding/ascii85
Decode decodes given input source(2nd param) into output(1st param), returning both the number of bytes written to output(1st param) and the number consumed from source(2nd param). If source contains invalid ascii85 data, Decode will return the number of bytes successfully written and a CorruptInputError. Decode ignores space and control characters in src. Often, ascii85-encoded data is wrapped in <~ and ~> symbols. Decode expects these to have been stripped by the caller.
If flush is true, Decode assumes that src represents the end of the input stream and processes it completely rather than wait for the completion of another 32-bit block.
NewDecoder wraps an io.Reader interface around Decode.
Golang encoding/ascii85.Decode function usage example
package main
import (
"encoding/ascii85"
"fmt"
)
func main() {
// encoded message
src := "9jqo^BlbD-BleB1DJ+*+F(f,q/0JhKF<GL>Cj@.4Gp$d7F!,L7@<6@)/0JDEF<G%<+EV:2F!,\n" +
"O<DJ+*.@<*K0@<6L(Df-\\0Ec5e;DffZ(EZee.Bl.9pF\"AGXBPCsi+DGm>@3BB/F*&OCAfu2/AKY\n" +
"i(DIb:@FD,*)+C]U=@3BN#EcYf8ATD3s@q?d$AftVqCh[NqF<G:8+EV:.+Cf>-FD5W8ARlolDIa\n" +
"l(DId<j@<?3r@:F%a+D58'ATD4$Bl@l3De:,-DJs`8ARoFb/0JMK@qB4^F!,R<AKZ&-DfTqBG%G\n" +
">uD.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c\n"
newbuffer := make([]byte, len(src))
_, _, err := ascii85.Decode(newbuffer, []byte(src), true)
if err != nil {
fmt.Println(err)
}
// print out the decoded message
fmt.Println(string(newbuffer))
}
Output :
Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.
References :
See also : Golang encoding/ascii85.Encode function example
Advertisement
Something interesting
Tutorials
+19.3k Golang : Check if directory exist and create if does not exist
+15.3k Golang : How to get Unix file descriptor for console and file
+5.8k Golang : Markov chains to predict probability of next state example
+17.5k Golang : Get future or past hours, minutes or seconds
+9.5k Facebook : Getting the friends list with PHP return JSON format
+17.1k Golang : Covert map/slice/array to JSON or XML format
+25.3k Golang : Convert uint value to string type
+7.1k Restart Apache or Nginx web server without password prompt
+10.9k Golang : Get UDP client IP address and differentiate clients by port number
+5.2k Golang : Issue HTTP commands to server and port example
+20.1k Golang : How to run your code only once with sync.Once object
+15.5k Golang : Find location by IP address and display with Google Map