Skip to content

Instantly share code, notes, and snippets.

@salrashid123
salrashid123 / main.py
Last active Jul 6, 2022
Using TINKKEY to create EncryptedKeyset for BigQuery
View main.py
# 1. Create KEK in KMS
# 2. Use TinkKey to generate DEK and wrap that with KEK (i.,e encryptedKeyset)
# 3. use python tink to encrypt some data with wrappeed DEK keyset
# 4. Use BQ functions to decrypt data using ciphertext in 3 and EncryptedKeyset in 2
# ref
# https://blog.salrashid.dev/articles/2022/bq_kms/
# https://github.com/salrashid123/tink_samples/
View getsamlassertion.py
#!/usr/bin/python
import base64
import datetime
import getopt
import random
import sys
import time
@salrashid123
salrashid123 / gemerate.go
Created Jun 26, 2022
Create or import new KMS TINK key for BigQuery SQL column-level encryption https://blog.salrashid.dev/articles/2022/bq_kms/
View gemerate.go
package main
import (
"bytes"
"encoding/base64"
"flag"
"fmt"
"math/rand"
"github.com/google/tink/go/aead"
@salrashid123
salrashid123 / decrypt.go
Last active Jul 18, 2022
Decrypt encrypted data for BigQuery SQL column-level encryption https://blog.salrashid.dev/articles/2022/bq_kms/
View decrypt.go
package main
import (
"bytes"
"encoding/base64"
"flag"
"fmt"
"github.com/google/tink/go/aead"
@salrashid123
salrashid123 / main.py
Created Jun 22, 2022
google healthcare api client using discovery and authorized session (https://cloud.google.com/healthcare-api/docs/how-tos/nlp)
View main.py
import httplib2
import google.auth
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
from oauth2client.client import GoogleCredentials
from google.api_core import operations_v1
from google.api_core import operation
from google.auth.transport.requests import AuthorizedSession
project_id = 'yourproject'
@salrashid123
salrashid123 / hmacsha.go
Last active Jun 21, 2022
hmac signedURL for GCS
View hmacsha.go
package main
import (
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"flag"
"fmt"
"io"
"net/http"
View main.go
package main
import (
"encoding/json"
"flag"
"fmt"
"time"
"golang.org/x/net/context"
@salrashid123
salrashid123 / main.go
Last active Jun 6, 2022
gRPC healthcheck using curl
View main.go
package main
/*
grpc Healthcheck from scratch
https://blog.salrashid.dev/articles/2022/grpc_healthcheck_curl/
*/
View xds_client_logs.log
$ go run src/grpc_client.go --host xds:///be-srv
2022/06/04 08:04:55 INFO: [core] [Channel #1] Channel created
2022/06/04 08:04:55 INFO: [core] [Channel #1] original dial target is: "xds:///be-srv"
2022/06/04 08:04:55 INFO: [core] [Channel #1] parsed dial target is: {Scheme:xds Authority: Endpoint:be-srv URL:{Scheme:xds Opaque: User: Host: Path:/be-srv RawPath: ForceQuery:false RawQuery: Fragment: RawFragment:}}
2022/06/04 08:04:55 INFO: [core] [Channel #1] Channel authority set to "be-srv"
2022/06/04 08:04:55 INFO: [xds] [xds-resolver 0xc0003a0cc0] Creating resolver for target: {Scheme:xds Authority: Endpoint:be-srv URL:{Scheme:xds Opaque: User: Host: Path:/be-srv RawPath: ForceQuery:false RawQuery: Fragment: RawFragment:}}
2022/06/04 08:04:55 INFO: [xds] [xds-bootstrap] Bootstrap content: {
"xds_servers": [
{
View server_tmpl.yaml
admin:
access_log_path: /dev/null
address:
socket_address:
address: 127.0.0.1
port_value: 9000
node:
cluster: service_greeter
id: test-id
static_resources: