Skip to content

Instantly share code, notes, and snippets.

@SaveTheRbtz
Last active September 28, 2021 15:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaveTheRbtz/246eab8557b0217ab3945e15cef6ffe8 to your computer and use it in GitHub Desktop.
Save SaveTheRbtz/246eab8557b0217ab3945e15cef6ffe8 to your computer and use it in GitHub Desktop.
DEG2021
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: choices.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor.FileDescriptor(
name='choices.proto',
package='',
syntax='proto3',
serialized_options=None,
create_key=_descriptor._internal_create_key,
serialized_pb=b'\n\rchoices.proto\"\x17\n\x07\x43hoices\x12\x0c\n\x04\x64\x61ta\x18\x01 \x03(\rb\x06proto3'
)
_CHOICES = _descriptor.Descriptor(
name='Choices',
full_name='Choices',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='data', full_name='Choices.data', index=0,
number=1, type=13, cpp_type=3, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key),
],
extensions=[
],
nested_types=[],
enum_types=[
],
serialized_options=None,
is_extendable=False,
syntax='proto3',
extension_ranges=[],
oneofs=[
],
serialized_start=17,
serialized_end=40,
)
DESCRIPTOR.message_types_by_name['Choices'] = _CHOICES
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
Choices = _reflection.GeneratedProtocolMessageType('Choices', (_message.Message,), {
'DESCRIPTOR' : _CHOICES,
'__module__' : 'choices_pb2'
# @@protoc_insertion_point(class_scope:Choices)
})
_sym_db.RegisterMessage(Choices)
# @@protoc_insertion_point(module_scope)
import psycopg2
import psycopg2.extras
import json
import six
import nacl.utils
from nacl.public import PrivateKey, PublicKey, Box
from choices_pb2 import Choices
# XXX: enc = {...}
skey = PrivateKey(bytes.fromhex("54e3cf70f712b2ff727bde3849772fa811a9d5de796aa7d788d205aa86af04ad"))
pkey = PublicKey(bytes.fromhex(enc['public_key']))
box = Box(skey, pkey)
pb = box.decrypt(bytes.fromhex(enc['encrypted_message']), bytes.fromhex(enc['nonce']))
offset = int.from_bytes(pb[:2], 'big')+2
choices = Choices().FromString(pb[offset:])
print(choices.data)
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment