Return to Level1Techs.com

Post your coding projects

programming

#202

Sounds weird, what exactly did you mean by this?


#203

The program needs SSH access to the server in order to issue that start command.

In order to do this, I need a username and password in order to log in. Which means that I need to store the password for user convenience; so they dont have to enter it ever time.

I want to write out the configuration to a text file. It is not secure to store a plain text password. That is where salt and hashing comes in.

Hashing the password will generate a 32 (i think) character alpha/numeric output. This hash is then stored. When the user enters there password, it is ran through the hash, if the hashes match, that means the user entered to correct password, and access is granted.

The problem with just hashing is that it can be hacked, because the hash will always be the same for the given password. This is where “salting” comes in.

Salt generates a random string of characters, this set of characters is the added to the password, and the combination of the salt and password are then hashed.

This way, when the user enters their password, the salt is added, and then the combination is hashed. If the stored hash equals the hash of the salt plus entered password, access is granted.

The salt makes it so that hacking methods become terrible inefficient; they are mostly left with trying to brutr force the password, which is no longer as simple, as they must now guess the random salt pkus the correct password, and in the correct order.

I probably explained thay terribly. If I missed something, someone please let me know.


#204

Couldn’t you create an ssh key and provide that instead of dealing with passwords being properly hashed?


#205

My first ever proper programming project of a reasonable size.

It’s a chat bot for Twitch, that has just about anything I could think of adding. Commands, quotes, fully fledged point system, shout out other casters, ban for links and permit accordingly etc.

Re-inventing the wheel, but wanted to make it a small CLI app for DIY-ers. Written in golang and takes under 20 MB of ram.


#206

If what you want to be doing is asking for memory and telling it to go away that’s great.

If you have a more practical task like “listen on TCP port 80 and handle every incoming request concurrently” then you start to run into problems trying to express that in terms of “give me memory, take it back, change that pointer” operations.


#207

Never thought of that. Like I said, I am a newb programmer. I am always open to suggestions.

I like the idea. I will do some reading and see how to do it.


#208

I did some reading on SSH keys. The only issue I am seeing is this method seems to require a lot of configuration on the part of the user. I will do some more research and see if there is an easier way to implement this that does not require as much user interaction.


#209

Learning go

Objective: eat all the ram

package main

import (
    "fmt"
    "runtime"
)


func burn() {
    var hog []int
    for i := 0; i > -1; i++ {
        hog = append(hog, i)
    }
}

func run() {
    wait := make(chan bool)
    for i := 0; i < runtime.NumCPU(); i++ {
        go burn()
        fmt.Println("Initialized", i)
    }
    <-wait
}

func main() {
    run()
}

One weird thing is if I replace <-wait with for true {}, it basically idles and does not eat memory. I’m not passing any params to burn(), so I fail to see why. The channel just knows it’s being used for multiprocessing?


#210

You’re right that if that’s what you want to do, it’s very easy to express in C.

But just like @freqlabs already pointed out, that’s often not the kind of thing you want to express when programming. Most programming jobs in the world are in business domains like finance, healthcare,… You name it. When programming things for people in that domain, you’ll want to create the same feeling in your code as what you described for C.

For example: having an account object with a transfer method that transfers money to another object. Calling the method just makes the transfer happen, very straightforward. You want your code to be full of those ‘domain’ terms. And they’re very far removed from getting a free chunk of memory and pointer arithmetic.

And that’s where these higher-level languages like ruby shine. They get you to a point where you (almost) don’t have to care about these machine operations anymore. It’s mostly handled for you by the language/runtime. As a result you lose some performance, but on the other hand you get to focus more on the domain you’re working in.


#211

compiler optimization? With the for true {} you are not using the wait chan. I know gcc doesn’t bother compiling unused variables in c++, but I am new to golang soooooo I’m not too sure


#212

@khaudio, I was able to check this in c++ by compiling to assembly with and without and running diff on them, which told me that they were identical files. Apparently, the go tool compiler has -S flag that will print Assembly code. Test away my friend!

sauce


#213

I wrote a primitive network audio player that is async for some reason

Uses UDP sockets currently but may change to TCP later on.
The idea is to create a DIY whole-home audio system.
The ultimate idea is to have an app that activates “party mode,” which takes priority on every device running this server and immediately plays daft punk while the lights in the house go crazy with RGB. Right now the app works and this linked thing works, so it’s kind of close.


#214

Sometimes I want to scan files before I crack em open on windows, but I don’t do it often enough to even remember the command. This reduces clamav upgrade, definition update, scanning with recursive options, and checking the output to one command.


#215

not that much coding stuff, did some testing/fine tuning of some install scripts for arch :stuck_out_tongue:


#216

I overhauled this over the weekend. It’s much more fleshed out now and abandons rsync for rclone so it can target cloud storage (as well as sftp and local storage).

I’ll combine it with another script that compiles a report of backup activity in a periodic notification email.

I developed my bash style in pretty much a complete vacuum, I’d be curious to see what a more seasoned person thinks of it.