Skip to content

Instantly share code, notes, and snippets.

View coderdan's full-sized avatar
🔐
Encrypting things

Dan Draper coderdan

🔐
Encrypting things
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:re="http://purl.org/atompub/rank/1.0">
<title type="text">Active questions tagged rust - Stack Overflow</title>
<link rel="self" href="https://stackoverflow.com/feeds/tag/rust" type="application/atom+xml" />
<link rel="alternate" href="https://stackoverflow.com/questions/tagged/?tagnames=rust&amp;sort=active" type="text/html" />
<subtitle>most recent 30 from stackoverflow.com</subtitle>
<updated>2025-05-09T11:56:01Z</updated>
<id>https://stackoverflow.com/feeds/tag/rust</id>
<creativeCommons:license>https://creativecommons.org/licenses/by-sa/4.0/rdf</creativeCommons:license>
<entry>
@coderdan
coderdan / fake_using.rb
Created April 3, 2023 04:20
Example of using encrypted values as deterministic seeds for Faker
require 'rubygems'
require 'faker'
def fake_using(hex_str)
prev_random = Faker::Config.random
Faker::Config.random = Random.new(hex_str.to_i(16))
result = yield
Faker::Config.random = prev_random
result
end
@coderdan
coderdan / yaml
Created February 16, 2023 00:27
Demo config
tables:
- path: users
fields:
- name: name
in_place: false
cast_type: utf8-str
mode: encrypted-duplicate
indexes:
- version: 1
kind: match
import { HasID, QueryResult, Stash } from "@cipherstash/stashjs"
import { movieSchema, Movie } from "./example-schema";
function displayResults(result: QueryResult<Movie & HasID>, name: string) {
result.documents.forEach((movie: Movie) => {
console.log(movie)
})
// TODO: print count
console.log("--------------------------------------------------")
console.log(name)
CREATE TYPE ore_block_64_8;
CREATE FUNCTION ore_block_in_64_8(cstring)
RETURNS ore_block_64_8
AS '$libdir/pgsecret'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION ore_block_out_64_8(ore_block_64_8)
RETURNS cstring
AS '$libdir/pgsecret'
["Crocodile", "Giraffe", "Lion", "Tiger"]
|> Enum.map(&String.capitalize/1)
|> Enum.sort
["Crocodile", "Giraffe", "Lion", "Tiger"].map { |word|
word.capitalize
}.sort
def print_name(%User{firstname: fname, lastname: lname}) do
"#{fname} #{lname}"
end
def print_name(%User{} = user) do
"#{user.firstname} #{user.lastname}"
end
def print_name(_) do
"Unknown"
end
def print_name(user)
if user.present? and user.kind_of?(User)
"#{user.firstname} #{user.lastname}"
else
"Unknown"
end
end