Skip to content

Instantly share code, notes, and snippets.

View ediskandarov's full-sized avatar
🛠️

Eduard Iskandarov ediskandarov

🛠️
View GitHub Profile
@ediskandarov
ediskandarov / node-cades-verify-signature.js
Created April 9, 2023 18:29
node cades script example that verifies attached signature
// Compile node module first `https://github.com/boriborm/cryptopro-node-cades`
const fs = require("node:fs");
const cades = require("./NodeCades");
const signedData = new cades.SignedData();
const message = fs.readFileSync("message.txt", { encoding: "utf-8" });
signedData.content = message; // string
const signatureRaw = fs.readFileSync("message.txt.sig"); // buffer
@ediskandarov
ediskandarov / cades.html
Created April 9, 2023 17:44
cades plugin by CryptoPro. Signature creation and verification
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8" />
<title>Проверки подписи</title>
<script language="javascript" src="cadesplugin_api.js"></script>
<script>
const { cadesplugin } = window;
class Certificate {
@ediskandarov
ediskandarov / pycades-verify-signature.py
Created April 9, 2023 17:43
pycades script example that verifies attached signature
import pycades
signed_data = pycades.SignedData()
with open('message.txt') as f:
msg = f.read()
signed_data.Content = msg
with open('message.txt.sig') as f:
signature_raw = f.read()
# Given an unsorted array, leftSum is defined as sum of all elements to the left of an element including the element
# and rightSum is defined as sum of all elements to the right of an element.
#
# Write a function that returns the minimum absolute difference between leftSum and rightSum.
#
# Example:
#
# Input: arr = [3,1,2,4,3]
# Output: 1
# Explanation:
@ediskandarov
ediskandarov / test-sns-sqs-publish-consume.py
Created January 14, 2021 05:08
A simple python script remonstrates SQS message consumption which was published to SNS
import time
import boto3
sns_client = boto3.client("sns", region_name='eu-central-1')
sqs_client = boto3.client("sqs", region_name="eu-central-1")
sns_client.publish(
TopicArn='arn:aws:sns:eu-central-1:386635533411:enveloped',
Message='test message',
MessageAttributes={
@ediskandarov
ediskandarov / hello.go
Created April 2, 2019 18:07
Golang hello world
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
@ediskandarov
ediskandarov / hex_to_str.py
Last active September 20, 2018 11:59 — forked from 0x63lv/hex_to_str.py
Script to convert Grafana SQLite dumps into PostgreSQL compatible dumps, and import it into PostgreSQL
#!/bin/env python
import fileinput
import re
import binascii
for line in fileinput.input(inplace = 1):
if re.search('X\'([a-fA-F0-9]+)\'', line) is not None:
unhexed_string = binascii.unhexlify(re.search('X\'([a-fA-F0-9]+)\'', line).group(1))
unhexed_string = unhexed_string.replace("'", "''")
@ediskandarov
ediskandarov / gist:fb494224ad781ec41c913e6718281966
Created September 20, 2018 05:29
Fetch a file from remote sever when there is no ssh or any other access
$ # compress a file and encode it in base64 format
$ gzip -k -c grafana.db | base64 - > grafana.db.gz.base64
$ # calculate md5 sum
$ md5sum grafana.db.gz.base64
$ # calculate md5 sum and compare results
$ md5sum grafana.db.gz.base64
$ # to decompress, reverse actions
$ base64 -D grafana.db.gz.base64 | gunzip > grafana.db
@ediskandarov
ediskandarov / grab_vimeo.py
Created March 17, 2017 19:53
Snippet to download private vimeo content
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import shutil
import sys
from urlparse import urljoin
import requests
@ediskandarov
ediskandarov / fields.py
Created February 25, 2013 11:10
django.forms.fields widget initialization
widget = widget or self.widget
if isinstance(widget, type):
widget = widget()