Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
github.com/lithammer/shortuuid/v3
A Go library that generates concise, unambiguous, URL-safe UUIDs. Based on and
compatible with the Python library
shortuuid
.
Often, one needs to use non-sequential IDs in places where users will see them, but the IDs must be as concise and easy to use as possible. shortuuid solves this problem by generating UUIDs using google/uuid and then translating them to base57 using lowercase and uppercase letters and digits, and removing similar-looking characters such as l, 1, I, O and 0.
package main
import (
"fmt"
"github.com/lithammer/shortuuid/v3"
)
func main() {
u := shortuuid.New() // Cekw67uyMpBGZLRP2HFVbe
}
To use UUID v5 (instead of the default v4), use NewWithNamespace(name string)
instead of New()
.
shortuuid.NewWithNamespace("http://example.com")
It's possible to use a custom alphabet as well, though it has to be 57 characters long.
alphabet := "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxy="
shortuuid.NewWithAlphabet(alphabet) // u=BFWRLr5dXbeWf==iasZi
Bring your own encoder! For example, base58 is popular among bitcoin.
package main
import (
"fmt"
"github.com/btcsuite/btcutil/base58"
"github.com/lithammer/shortuuid/v3"
"github.com/satori/go.uuid"
)
type base58Encoder struct {}
func (enc base58Encoder) Encode(u uuid.UUID) string {
return base58.Encode(u.Bytes())
}
func (enc base58Encoder) Decode(s string) (uuid.UUID, error) {
return uuid.FromBytes(base58.Decode(s))
}
func main() {
enc := base58Encoder{}
fmt.Println(shortuuid.NewWithEncoder(enc)) // 6R7VqaQHbzC1xwA5UueGe6
}
MIT
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.