File: README.md

package info (click to toggle)
golang-github-wellington-go-libsass 0.9.2%2Bgit20181130.4ef5b9d-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,128 kB
  • sloc: cpp: 28,607; ansic: 839; makefile: 44
file content (34 lines) | stat: -rw-r--r-- 676 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Cryptographically secure pseudorandom number generator in Sass. Well that is easy to do with this custom `crypto()` handler!

Start by registering a Sass function with the name `crypto()`. Now when `crypto()` is found in Sass, the cryptotext Go function will be called.

Input

``` sass
div { text: crypto(); }

```


Output

``` css
div {
  text: 'c91db27d5e580ef4292e'; }
```

Sass function written in Go

``` go
func cryptotext(ctx context.Context, usv libsass.SassValue) (*libsass.SassValue, error) {

	c := 10
	b := make([]byte, c)
	_, err := rand.Read(b)
	if err != nil {
		return nil, err
	}
	res, err := libsass.Marshal(fmt.Sprintf("'%x'", b))
	return &res, err
}
```